﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace DrWileyO_REDACTED_Adventure
{
    class Platform
    {
        Texture2D cap;
        Texture2D middlePieces;
        Vector2 position;
        int middleNumber;

        Rectangle hitBox;

        public Platform(Texture2D cap, Texture2D middle, int middleNum, Vector2 pos)
        {
            this.cap = cap;
            middlePieces = middle;

            middleNumber = middleNum;
            position = pos;
            hitBox = new Rectangle((int)position.X, (int)position.Y, this.cap.Width + middlePieces.Width * middleNumber + this.cap.Width, this.cap.Height);
        }

        public void Update(GameTime gTime)
        {
            hitBox = new Rectangle((int)position.X, (int)position.Y, this.cap.Width + middlePieces.Width * middleNumber + this.cap.Width, this.cap.Height);
        }

        public void Draw(GameTime gTime, SpriteBatch sBatch, float alpha)
        {
            sBatch.Draw(cap, position, Color.White);
            int acc = cap.Width;
            for (int i = 0; i < middleNumber; i++)
            {
                sBatch.Draw(middlePieces, new Vector2(position.X + acc, position.Y), Color.White);
                acc += middlePieces.Width;
            }
            Vector2 endPos = new Vector2(position.X + acc, position.Y); 
            sBatch.Draw(cap, endPos, null, Color.White, 0.0f, new Vector2(0,0), 1.0f, SpriteEffects.FlipHorizontally, 1.0f);
        }
    }
}
